<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	request.setAttribute("basePath", basePath);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'WorkFlow.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<jsp:include page="/scripts/common/index.html"></jsp:include>
<jsp:include page="/scripts/jquery/index.html"></jsp:include>
<jsp:include page="/scripts/dhtmlx/index.html"></jsp:include>
<jsp:include page="/scripts/bootstrap/index.html"></jsp:include>
<link rel="stylesheet" href="${basePath }style/default.css">
<script>
	var myGrid;
	var data = [
			[
					"100" ,
					"A Time to Kill" ,
					"John Grisham" ,
					"12.99" ,
					"1" ,
					"05/01/1998"
			] ,
			[
					"1000" ,
					"Blood and Smoke" ,
					"Stephen King" ,
					"0" ,
					"1" ,
					"01/01/2000"
			] ,
			[
					"1000" ,
					"Blood and Smoke" ,
					"Stephen King" ,
					"0" ,
					"1" ,
					"01/01/2000"
			]
	];
	function init() {
		clickFun();
		addNode();
		query();
	}
	function addNode() {
		var str = "<div id='example5' class='ezmodal'></div><input type='text' id='sucessUrl' style='display:none'/>";
		$("body").append(str);
	}
	function clickFun() {
		//新增
		$("#add").click(function() {
			SN.getWindowByUrl("新增XXX", "800", "400", "${basePath}page/model/WorkFlow/toAdd", {});
		});
		//新增主从
		$("#addChildTable").click(function() {
			SN.getWindowByUrl("新增XXX", "900", "400", "${basePath}page/model/WorkFlow/toAddChildTable", {});
		});
		//修改
		$("#update").click(function() {
			var v = getGridSelectValues(1);
			if (v.length == 1) {
				SN.getWindowByUrl("修改XXX", "800", "400", "${basePath}page/model/WorkFlow/toUpd", {
					"map.guid" : v
				});
			} else {
				SN.alert.error("请选择一条记录");
			}
		});
		//浏览
		$("#view").click(function() {
			var v = getGridSelectValues(1);
			if (v.length == 1) {
				SN.getWindowByUrl("浏览XXX", "800", "400", "${basePath}page/model/WorkFlow/toView", {
					"map.guid" : v
				});
			} else {
				SN.alert.error("请选择一条记录");
			}
		});
		//浏览主从
		$("#viewChildTable").click(function() {
			SN.getWindowByUrl("浏览XXX", "900", "400", "${basePath}page/model/WorkFlow/toViewChildTable", {});
		});
		//高级查询
		$("#query").click(function() {
			SN.getWindowByUrl("高级查询", "800", "400", "${basePath}common/AdvanceQuery.jsp", {});
		});
		//多页添加页面
		// 		$("#addMore").click(function(){
		// 			SN.getWindowByUrl("新增XXX","800","470","${basePath}page1/system/WorkFlowMore_Add.jsp",{});
		// 		});
		//上传
		// 		$("#upload").click(function(){
		// 			SN.getWindowByUrl("上传","800","470","${basePath}common/FileUpload.jsp",{});
		// 		});
		//下载
		// 		$("#download").click(function(){
		// 			SN.getWindowByUrl("上传","800","470","${basePath}common/FileDownload.jsp",{});
		// 		});
		//删除
		$("#delete").click(function() {
			var v = getGridSelectValues(1);
			SN.alert.confirm("是否要删除" + v.length + "数据！", function(obj) {
				if (obj) {
					var v = getGridSelectValues(1);//获取第n列选中数据
					$.ajax({
							type : 'POST' ,
							url : '${basePath}page/model/WorkFlow/doDel' ,
							data : {
								"map.guid" : v ,
							} ,
							dataType : "json" ,
							async : true ,
							cache : false ,
							jsonpCallback : "null" ,
							//beforeSend : function(response, status, statusText) {
							//alert(response + ":" + status + ":" + statusText);
							//} ,
							//dataFilter : function(response, status, statusText) {
							//alert(response + ":" + status + ":" + statusText);
							//} ,
							success : function(response, status, statusText) {
								//alert(response + ":" + status + ":" + statusText);
								if (response.status) {
										query();
								} else {
									alert(response.content);//提示信息
								}
							} ,
							error : function(response, status, statusText) {
								//alert(response + ":" + status + ":" + statusText);
							} ,
							complete : function(response, status, statusText) {
								//alert(response + ":" + status + ":" + statusText);
							}
					});
				}
			});
		});
		//重置
		$("#repeat").click(function() {
			window.location.reload();
		});
		//刷新
		$("#refresh").click(function() {
			query();
		});
	}
	function query() {
		var data = getValue();
		data["MAP.XXX"] = "XXX";
		$.ajax({
				type : 'POST' ,
				url : 'page/model/WorkFlow/query' ,
				data : data ,//获取工具条的分页信息
				dataType : "json" ,
				async : true ,
				cache : false ,
				jsonpCallback : "null" ,
				//beforeSend : function(response, status, statusText) {
				//alert(response + ":" + status + ":" + statusText);
				//} ,
				//dataFilter : function(response, status, statusText) {
				//alert(response + ":" + status + ":" + statusText);
				//} ,
				success : function(response, status, statusText) {
					console.debug(response);
					if (response.status) {
						var a = response.content.currentPageNum;
						var b = response.content.allPageNum;
						var c = response.content.allCount;
						setValue(a, b, c);
					} else {
						alert(response.content);
					}
				} ,
				error : function(response, status, statusText) {
					//alert(response + ":" + status + ":" + statusText);
				} ,
				complete : function(response, status, statusText) {
					//alert(response + ":" + status + ":" + statusText);
				}
		});
	}
</script>
</head>
<body onload="init()">
	<table class="listTableClass" border="0" cellpadding="0" cellspacing="0">
		<tr class="queryClass">
			<td>
				<table>
					<tr>
						<td style="width:3%">姓名：</td>
						<td style="width:20%"><input type="text" class="form-control"></td>
						<td>
							<button onclick="query()" class="btn btn-primary" type="button">
								<span>查询</span>
							</button>
							<button class="btn btn-primary" type="reset">
								<span>清空</span>
							</button>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr class="listTrClass">
			<td>
				<table class="listTableClass">
					<tr class="listContClass">
						<td>
							<div>
								<button class="btn btn-primary" id="add">
									<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> &nbsp; <span>新增</span>
								</button>
								<button class="btn btn-primary" id="update">
									<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> &nbsp; <span>修改</span>
								</button>
								<button class="btn btn-primary" id="view">
									<span class="glyphicon glyphicon-file" aria-hidden="true"></span> &nbsp; <span>浏览</span>
								</button>
								<button class="btn btn-primary" id="delete">
									<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> &nbsp; <span>删除</span>
								</button>
								<button class="btn btn-primary" id="refresh">
									<span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> &nbsp; <span>刷新</span>
								</button>
								<button class="btn btn-primary" id="repeat">
									<span class="glyphicon glyphicon-repeat" aria-hidden="true"></span> &nbsp; <span>重置</span>
								</button>
								<button class="btn btn-primary" id="exportNow">
									<span class="glyphicon glyphicon-export" aria-hidden="true"></span> &nbsp; <span>导出当前页</span>
								</button>
								<button class="btn btn-primary" id="exportAll">
									<span class="glyphicon glyphicon-export" aria-hidden="true"></span> &nbsp; <span>导出全部</span>
								</button>
							</div>
						</td>
					</tr>
					<tr class="listTrClass">
						<td><jsp:include page="/common/grid_toolbar.jsp">
								<jsp:param value="query" name="func" />
								<jsp:param value="setValue" name="setValue" />
								<jsp:param value="getValue" name="getValue" />
								<jsp:param value="getGrid" name="getGrid" />
								<jsp:param value="getGridSelectValues" name="getGridSelectValues" />
								<jsp:param value="true" name="isPaging" />
							</jsp:include></td>
					</tr>
					<tr class="listTrClass" style="height: 10px;">
						<td><span id="page_message"></span></td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</body>
</html>
